package com.eusoft.demo.utils;

import com.eusoft.demo.entity.Result;

/**
 * 返回数据格式工具类
 */
public class ResultUtils {
    public static Result<Object> success(Object data, String msg){
        Result<Object> result = new Result<>();
        result.setCode(200);
        result.setStatus(true);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }
    public static Result<Object> error( String msg){
        Result<Object> result = new Result<>();
        result.setCode(401);
        result.setStatus(false);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }

    public static Result<Object> newData(Object data,String msg,Integer code,Boolean flag){
        Result<Object> result = new Result<>();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        result.setStatus(flag);
        return result;
    }
}
